import axios from 'axios'
import useUserStore from '@/stores/user'

const instance = axios.create({
  baseURL: 'http://localhost:5173/ftyyptapi',
})

// 请求拦截器
instance.interceptors.request.use(
  (config) => {
    // do something
    const user = useUserStore()
    if (user.userInfo.token) {
      config.headers.Token = user.userInfo.token
    }

    return config
  },
  (error) => {
    return Promise.reject(error)
  },
)
// 响应拦截器

export default instance
